package com.fzb.forum4j.incp;

import org.apache.struts2.interceptor.ActionMappingParametersInteceptor;

import com.fzb.forum4j.controller.CommonsAction;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;

public class AdminInterceptor extends ActionMappingParametersInteceptor {

	 
	/**
	 * 
	 */
	private static final long serialVersionUID = -9187502519262181968L;

	public String doIntercept(ActionInvocation invocation) throws Exception {
		
		long s=System.currentTimeMillis();
		if(invocation.getInvocationContext().getSession().get("adminMsg")==null)
		{
			System.out.println("未登陆过");
			return "login";
		}
		((CommonsAction)ActionContext.getContext().getValueStack().getRoot().get(0)).prepare();
		invocation.getStack().push(((CommonsAction)ActionContext.getContext().getValueStack().getRoot().get(0)).getModel());
		setParameters(invocation.getAction(), invocation.getStack(), invocation.getInvocationContext().getParameters());
		String str=invocation.invoke();
		System.out.println("拦截器耗费了"+(System.currentTimeMillis()-s));
		return str;
	}

}
